import java.util.Stack;

public class O09 {
    Stack<Integer> stack;
    Stack<Integer> stack1;
    public O09() {
        stack = new Stack<>();
        stack1 = new Stack<>();
    }

    public void appendTail(int value) {
        stack.push(value);
    }

    public int deleteHead() {
        while (!stack.empty()){
            stack1.push(stack1.pop());
        }
        int re = stack1.empty()?-1:stack.pop();
        while (!stack1.empty()){
            stack.push(stack1.pop());
        }
        return re;
    }
}
